from flask import Flask, request
from flask_cors import CORS
from dataUtil import mongoConnect
import json
import setproctitle

app = Flask(__name__)
CORS(app, resources={r'/*'}, supports_credentials=True)


@app.route("/query_platform", methods=["POST", "GET"])
def query_platform():
    print("here")
    results = {
        "storageService": [
            {
                'unitName': "mongoDb",
                'unitStatus': "running",
                'unitCom': "60%",
            },
            {
                'unitName': "Hive",
                'unitStatus': "running",
                'unitCom': "40%",
            },
        ],
        'computeService': [
            {
                'unitName': "SparkSql",
                'unitStatus': "running",
                'unitCom': "60%",
            },
        ],
        'profileService': [
            {
                'unitName': "Item",
                'unitStatus': "running",
                'unitCom': "60%",
            },
        ],
        'funcService': [
            {
                'unitName': "AntiPoor",
                'unitStatus': "running",
                'unitCom': "60%",
            },
        ],
    }
    return json.dumps(results, ensure_ascii=False)


if __name__ == "__main__":
    setproctitle.setproctitle("bdmo-plat")
    app.debug = True
    app.run(host='0.0.0.0', port=5003)
